package demo2;

import lombok.Data;
import lombok.ToString;

@Data
@ToString
public class Phone {

    private String cpu;
    private String screen;
    private String memory;
    private String mainBoard;

    private Phone(Builder builder){
        this.cpu = builder.cpu;
        this.screen = builder.screen;
        this.mainBoard = builder.memory;
        this.memory = builder.memory;
    }

    //也可以在这里加上一些形参列表 限定必须传的参数
    public static final class Builder{
        private String cpu;
        private String screen;
        private String memory;
        private String mainBoard;

        public Builder cpu(String cpu){
            this.cpu = cpu;
            return this;
        }

        public Builder screen(String screen){
            this.screen = screen;
            return this;
        }

        public Builder memory(String memory){
            this.memory = memory;
            return this;
        }

        public Builder mainBoard(String mainBoard){
            this.mainBoard = mainBoard;
            return this;
        }

        public Phone build(){
            return new Phone(this);
        }
    }
}
